#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>
#include<vector>

using namespace std;

string Max_Public(string& str1, string& str2)
{
    if (str1.size() > str2.size())
    {
        swap(str1, str2);
    }

    int leng1 = str1.size();
    int leng2 = str2.size();

    vector<vector<int>> GP(leng1 + 1, vector<int>(leng2 + 1, 0));
    int start = 0;
    int max_size = 0;

    for (int i = 1; i <= leng1; ++i)
    {
        for (int j = 1; j <= leng2; ++j)
        {
            if (str1[i - 1] == str2[j - 1])
            {
                GP[i][j] = GP[i - 1][j - 1] + 1;
            }

            if (GP[i][j] > max_size)
            {
                max_size = GP[i][j];
                start = i - max_size;
            }
        }
    }
    return str1.substr(start, max_size);
}

int main()
{
    string str1;
    string str2;

    while (cin >> str1 >> str2)
    {
        string s = Max_Public(str1, str2);
        int t = s.size();
        cout << t << endl;
    }
    return 0;
}